package com.wardrobe.soa.api.practitioners;

import com.wardrobe.domain.practitioners.PractitionersShowBean;
import com.wardrobe.soa.api.home.HomeInfoResponse;
import com.wardrobe.soa.common.ApiResult;
import com.wardrobe.soa.utils.CommonConsant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018/11/30.
 */
@RestController
@RequestMapping("/api/practitioners")
public class PractitionersController {
    private static final Logger logger = LoggerFactory.getLogger(PractitionersController.class);

    @Autowired
    private PractitionersService practitionersService;

    @RequestMapping("/searchPractitionersByName")
    public ApiResult searchPractitionersByName(String name){
        try {
            List<PractitionersShowBean> practitionersShowBeans = practitionersService.searchPractitionersByName(name);
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,practitionersShowBeans);
        }catch (Exception e){
            logger.error("searchPractitionersByName_err",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }

    @RequestMapping("/getPractitionersDetail")
    public ApiResult getPractitionersById(int id){
        try {
            PractitionersShowBean practitioners= practitionersService.getPractitionersById(id);
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,practitioners);
        }catch (Exception e){
            logger.error("getPractitionersById_err",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }
}
